package edu.fiu.cis.selfhealingdisk;

/**
 * @author Barbara Espinoza
 */
public class DiskSimJNIInterface {
	
	public static final int DISKSIM_WRITE = 0x00000000;
	public static final int DISKSIM_READ = 0x00000001;
	public static final int DISKSIM_READ_AFTR_WRITE = 0x00000040;
	
	static {
		System.loadLibrary("disksim_jni_interface");
	}
	
	public DiskSimJNIInterface() {
		
	}
	
	/**
	 * Starts up DiskSim.
	 * 
	 * @param parameterFile
	 * @param outputFile
	 */
	public native void startSimulation(String parameterFile, String outputFile);
	
	/**
	 * Sends a request to DiskSim.
	 * 
	 * @param timestamp time in which the request is sent
	 * @param requestType type of the request
	 * @param requestId id of the request
	 * @param block block number
	 * @param byteCount number of bytes
	 * @param 
	 */
	public native void sendRequest(long timestamp, int requestType, long block, long byteCount, long requestId);
	
	/**
	 * Advances Disksim's clock until the given timestamp.
	 * 
	 * @param timestamp in nanoseconds
	 */
	public native void setTime(long timestamp);
	
	/**
	 * Get all the events finished up to DiskSim's time and clear the event list.
	 * 
	 * @param timestamp
	 * @return
	 */
	public native long[] getEvents();

	/**
	 * Advances the clock until no outstanding events are pending.
	 * Generates DiskSim's output file
	 */
	public native void finishSimulation();
	
}
